package cn.aiweiyi.qingjing.coupon.comm.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author 青衿
 * @Date 2020/11/14 14:45
 * 重写WebConfigurer接口的configureMessageConverters方法
 * 定制SpringMvc框架中的Http消息转换器
 **/
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        System.out.println("0--");
        converters.clear();//先清空框架默认所有消息转化器
        converters.add(new MappingJackson2HttpMessageConverter());
    }
    //该消息转换器把java对象转为JSON后,还会设置响应的没踢类型为application/json
}
